package cn.itcast.service.impl;

import cn.itcast.dao.StandardDao;
import cn.itcast.domain.Standard;
import cn.itcast.service.StandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StandardServiceImpl implements StandardService {
    @Autowired
    private StandardDao standardDao;

    /**
     * 添加或者查询
     * @param standard
     */
    @Override
    public void save(Standard standard) {
        standardDao.save(standard);
    }

    /**
     * 分页查询
     * @param page
     * @param rows
     * @return
     */
    @Override
    public Page<Standard> pageQuery(int page, int rows) {
        PageRequest pageable = PageRequest.of(page - 1, rows);
        return standardDao.findAll(pageable);
    }

    @Override
    /**
         * 查询所有
         * @return
         */
        public List<Standard> standardFindAll(){
            return  standardDao.findAll();
        }
    }

